package com.aiprompt.demos.controller;

import com.aiprompt.demos.common.BaseResponse;
import com.aiprompt.demos.common.ResultUtils;
import com.aiprompt.demos.exception.ErrorCode;
import com.aiprompt.demos.exception.ThrowUtils;
import com.aiprompt.demos.model.dto.prompt.PromptGenerateRequest;
import com.aiprompt.demos.service.GenerateService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/generater")
public class GeneraterController {
    @Resource
    private GenerateService generateService;

    @PostMapping("/prompt")
    public BaseResponse<String> generateOutputText(@RequestBody PromptGenerateRequest promptGenerateRequest) {
        ThrowUtils.throwIf(promptGenerateRequest == null, ErrorCode.PARAMS_ERROR);
        String result = generateService.GenerateOutputText(promptGenerateRequest);
        return ResultUtils.success(result);
    }
}
